<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="superviseMenu" />
<meta name="nav" content="2" />
<meta name="acc" content="0" />
<title>交工检测申请</title>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$("#orgName").focus();
						$("#inputForm").validate({
							event : "blur",
							isTip : true
						});

						var date = new Date();
						$.get(
								"${ctx}/business/history/history!info.action?key=${fid}&time="
										+ date, function(data) {
									$("#frame").html(data);
								});

						$("#value")
								.click(
										function() {
											var url = "${ctx}/account/json/userchooses.action";
											var obj = new Object();
											mm = window
													.showModalDialog(
															url,
															obj,
															'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
																	+ (screen.width / 2.0 - 150)
																	+ ',dialogTop:170')
											if (mm != null) {
												$("input[name='value']")
														.val(mm);
											}
										});

						$("#reportDate").addClass("Wate").bind("click",
								function() {
									WdatePicker({
										skin : 'whyGreen',
										maxDate : '%y-%M-%d',
										dateFmt : 'yyyy-MM-dd'
									});
								});

					});

	var i = 1;
	function addFile(divName, fileName) {
		var dv = document.getElementById(divName);

		var file = document.createElement("input");
		file.type = "file";
		file.name = fileName;
		file.id = fileName + i;
		dv.appendChild(file);

		var btn = document.createElement("input");
		btn.type = "button";
		btn.id = btn.name = "btn" + i;
		btn.value = "删除";

		btn.onclick = function() {
			var b = document.getElementById(btn.id);
			dv.removeChild(b.nextSibling);
			dv.removeChild(b.previousSibling);
			dv.removeChild(b);
		}

		dv.appendChild(btn);
		dv.appendChild(document.createElement("BR"));

		i++;
	}
</script>
</head>
<body>
	<form action="${ctx}/business/acct/report!save.action" method="post"
		id="inputForm" class="yform" enctype="multipart/form-data">
		<input type="hidden" id="id" name="id" value="${id }"> <input
			type="hidden" name="taskid" id="taskid"
			value="${(empty taskid)?taskId : taskid}"> <input
			type="hidden" name="taskId" id="taskId"
			value="${(empty taskid)?taskId : taskid}"> <input
			type="hidden" name="projectId" id="projectId" value="${projectId}">
		<input type="hidden" name="fid" id="fid" value="${fid}">
		<div id="caption">
			<h6>工程质量检测报告</h6>
		</div>
		<div>
			<table class="noborder">
				<tr class="type-text">
					<td>项目名称</td>
					<td><input type="text" name="projName" id="projName"
						value="<pt:labels type="proj" argument1="${projectId }" single="true"></pt:labels>"
						readonly="readonly"></td>
				</tr>
				<tr class="type-text">
					<td>合同段</td>
					<td><pt:labels type="sign" argument1="${cid }" single="true"></pt:labels>
						<input type="hidden" name="cid" id="cid" value="${cid }"></td>
				</tr>
				<tr class="type-text">
					<td>收文单位</td>
					<td><input type="text" name="orgName" id="orgName"
						value="${orgName }" class="required"></td>
				</tr>
				<tr class="type-text">
					<td>报告出具时间</td>
					<td><input type="text" name="reportDate" id="reportDate"
						value='<fmt:formatDate value="${reportDate }" pattern="yyyy-MM-dd"/>'
						class="required"></td>
				</tr>
				<tr class="type-text">
					<td>报告关键内容</td>
					<td><textarea name="content" id="content" class="required">${content }</textarea>
					</td>
				</tr>
				<tr class="type-text">
					<td>备注</td>
					<td><textarea name="remark" id="remark">${remark}</textarea></td>
				</tr>
				<tr class="type-text">
					<td><input type="button" value="添加上传"
						onclick="addFile('sources','upload')"></td>
					<td id="sources"></td>
				</tr>
			</table>
			<c:if test="${not empty attachments }">
				<div id="caption">
					<h6>已有附件</h6>
				</div>
				<table>
					<c:forEach items="${attachments }" var="attachment"
						varStatus="state">
						<tr id="tr${state.index }">
							<td colspan="4"><a title="下载"
								href="${ctx}/servlet/annex?id=${attachment.id}">${attachment.upfileFileName}(${attachment.type})<fmt:formatDate
										value="${attachment.fileTime}" pattern="yyyy-MM-dd" />
							</a> <span
								onclick="deleteAttachmentById('${attachment.id}','tr${state.index }')"
								class="delete" title="删除附件"></span></td>
						</tr>
					</c:forEach>
				</table>
			</c:if>
		</div>
		<div class="type-button">
			<input type="submit" class="submit" value="下一步" /> <input
				type="button" class="reset" value="返回"
				onclick="window.location.href='${ctx}/business/acceptance!first.action?taskid=${taskid}&id=${fid}&projectId=${projectId}'">
		</div>
	</form>
</body>
</html>